<?php
function __autoload($class){
    $part = explode('_', $class);
    $size = count($part);
    $path = '';
    for ($i=0; $i<$size-1;$i++){
        $part[$i]=strtolower($part[$i]);
        $path = $path.'/'.$part[$i];
    }
    include ($path.'/'.$class.'.php');
}

Lib_Session::start();
Lib_Profiler::start();
Lib_Registry::initDatabase();
Lib_Registry::setRegistry('host', $_SERVER['HTTP_HOST']);
Lib_Registry::setRegistry('root', dirname($_SERVER['PHP_SELF']));
Lib_Router::init();
Lib_Router::setDefaultRoute(array("module"=>"public", "controller"=>"movies", "action"=>"index"));
Lib_Router::addRoute("admin/movies/([0-9]+)", array("module"=>"admin","controller"=>"movies", "action"=>"detail"));
Lib_Router::addRoute("admin/movies/insert", array("module"=>"admin","controller"=>"movies", "action"=>"insert"));
Lib_Router::addRoute("admin/movies", array("module"=>"admin","controller"=>"movies", "action"=>"index"));

Lib_Router::resolve();
Lib_Profiler::end();
?>
